/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package readwritefile;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;

/**
 *
 * @author sochy
 */
public class DemoWriteFile {
    public static void main(String[] args) {
        
        MyFile obj = new MyFile();
        
        ArrayList<String> data = new ArrayList<String>();
        
        data.add("A");
        data.add("B");
        data.add("C");
        
        
        try {
            // write data into file
            obj.writeSmallTextFile(data, "C:\\Users\\sochy\\Desktop\\test.txt");
            // Read data from file
            MyFile o = new MyFile();
            List<String> d = o.readSmallTextFile("C:\\Users\\sochy\\Desktop\\test.txt");
            for(String s: d){
                System.out.println(s);
            }       
            
        } catch (IOException ex) {
            
            JOptionPane.showMessageDialog(null, "File cannot write, please check the permission!!!");
        }
    }
}
